package com.cxy.controller.user;

import com.cxy.dto.UpdatePassWordDTO;
import com.cxy.result.Result;
import com.cxy.service.UserService;
import com.cxy.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;
import java.util.List;
@Api(tags = "用户端相关接口")
@RestController("userController")
@RequestMapping("/user")
@Slf4j
public class UserController {
    @Autowired
    private UserService userService;
    /**
     * 修改密码
     */
    @ApiOperation("修改密码业务功能")
    @PutMapping("/uupw")
    public Result userUpdatePassword(@RequestBody UpdatePassWordDTO updatePassWordDTO){
        userService.userUpdatePassWord(updatePassWordDTO);
        return Result.success();
    }
    /**
     * 查看当前用户的评议·任务
     */
    @ApiOperation("查看当前用户的评议任务")
    @GetMapping("/seeAssess")
    public Result<SeeAssessVO>seeAssess(){
       SeeAssessVO list = userService.seeAssess();
       return Result.success(list);
    }

    /**
     * 用户评议详细
     */
    @ApiOperation("用户评议详细")
    @GetMapping("/assess/{id}")
    public Result<UserAssessVO> assess(@PathVariable Long id){
       UserAssessVO list= userService.assess(id);
        return Result.success(list);
    }
    /**
     * 用户评议打分
     */
    @ApiOperation("用户评议打分")
    @PutMapping("/mark")
    public Result mark( Long byReviewUserId ,Double score){
        userService.mark(byReviewUserId,score);
        return Result.success();
    }

    /**
     * 查看自身的评议记录
     */
    @ApiOperation("查看自身的评议记录")
    @GetMapping("/seeAssessRecord")
    public Result<List<AssessRecordVO>> seeAssessRecord(String dateNumber){
        log.info("当前的期数:{}",dateNumber);
        List<AssessRecordVO>list=userService.seeAssessRecord(dateNumber);
        return Result.success(list);
    }
    /**
     * 返回月榜（月榜默认显示最新生成的期数的榜单。）
     */
    @ApiOperation("返回月榜（月榜默认显示最新生成的期数的榜单。）")
    @GetMapping("/month")
    public Result<MonthTopVO>  month(){
        MonthTopVO list=userService.month();
        return Result.success(list);
    }
    /**
     * 返回季度榜(首页的季度榜”默认显示的是距离当前上一个季度的榜单)
     */
    @ApiOperation("返回季度榜(首页的季度榜”默认显示的是距离当前上一个季度的榜单)")
    @GetMapping("/quarter")
    public Result<QuarterTopVO> quarter(){
        QuarterTopVO list = userService.quarter();
        return Result.success(list);
    }
    /**
     * 往期榜单(月查询)
     */
    @GetMapping("/ageMonthTop")
    @ApiOperation("往期榜单(月查询)")
    public Result<MonthTopVO> ageMonthTop( String YearAndMonth) throws ParseException {
       MonthTopVO monthTopVO = userService.ageMonthTop(YearAndMonth);
       return Result.success(monthTopVO);
    }
    /**
     * 往期榜单（季查询）
     */
    @GetMapping("/ageQuarterTop")
    @ApiOperation("往期榜单(月查询)")
    public Result<QuarterTopVO> ageQuarterTop( String year,String season){
        QuarterTopVO quarterTopVO = userService.ageQuarterTop(year,season);
        return Result.success(quarterTopVO);
    }
}
